package course.web;
import course.domain.Personal;

import javax.validation.Valid;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.SessionAttributes;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;

@SessionAttributes(value="personal",types= {Personal.class})
@Slf4j
@Controller
@RequestMapping("/personal")

public class PersonalController{
	@GetMapping
	public String personalForm(Model model) {
		model.addAttribute("personal", new Personal());
		return "personal";
	}
	@PostMapping
	public String processPersoninfo(@Valid @ModelAttribute("personal") Personal person,Errors errors) {
		if(errors.hasErrors()) {
			 return "personal";
		 }
		log.info("进一步选课:"+person);
		return "redirect:/selection";
	}
	
	
}
